package com.rdc.qingkou.dto;


import com.rdc.qingkou.Application.MyApplication;
import com.rdc.qingkou.R;
import com.rdc.qingkou.config.URL;
import com.rdc.qingkou.entity.User;
import com.rdc.qingkou.utils.MyUtils;
import com.rdc.qingkou.vo.UserVO;

public class UserInfoDTO {

    private String result;
    private User user;

    public UserVO transform() {
        UserVO userVO = new UserVO();
        userVO.setSubsribeStatus(false);
        userVO.setUserId(user.getUserId());
        if (user.getNickName() == null || user.getNickName().equals("")) {
            userVO.setNickName("路人甲");
        } else {
            userVO.setNickName(user.getNickName().replace("\"", ""));
        }
        if (user.getImageUrl() == null || user.getImageUrl().equals("")) {
            userVO.setHeadImageUrl(MyUtils.getUriFromDrawableRes(MyApplication.getContext(), R.drawable.imageview_default_head));
        } else {
            if (user.getImageUrl().startsWith("/Qing_kou/")) {
                userVO.setHeadImageUrl("http://120.78.74.103" + user.getImageUrl());
            } else {
                userVO.setHeadImageUrl(URL.HEAD_YUN + user.getImageUrl());
            }
        }
        if (user.getSignature() == null || user.getSignature().equals("")) {
            userVO.setSignature("这个人很懒，什么也没有写。");
        } else {
            userVO.setSignature(user.getSignature().replace("\"", ""));
        }
        return userVO;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }
}
